/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConexaoSingleton {

    private static ConexaoSingleton instancia;
    private Connection connection = null;

    // cria um novo objeto ConnectionSingleton
    // Note que o construtor é privado. Significa que somente a partir desta classe é
    // possível criar objetos ConnectionSingleton
    private ConexaoSingleton() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection("jdbc:mysql://localhost/projetointegrador11",
                    "root", "1");
        } catch (SQLException sqle) {
            sqle.printStackTrace();
        } catch (ClassNotFoundException cnfe) {
            cnfe.printStackTrace();
        }
    }

    public static ConexaoSingleton getInstance() {
        if (instancia == null) {
            instancia = new ConexaoSingleton();
        }
        return instancia;
    }

    public Connection getConnection() {
        return connection;
    }
}